package com.hnevc.wangyu.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hnevc.wangyu.R;
import com.hnevc.wangyu.bean.UserBean;

import java.util.List;

public class UserAdapter extends BaseAdapter {

    private Context context;
    private List<UserBean> list;

    public UserAdapter(Context context, List<UserBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.user_item_layout, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }
        viewHolder = (ViewHolder) convertView.getTag();
        UserBean userBean = list.get(position);
        viewHolder.user_item_name.setText("");
        return convertView;
    }

    public static
    class ViewHolder {
        public View rootView;
        public ImageView user_item_img;
        public TextView user_item_name;

        public ViewHolder(View rootView) {
            this.rootView = rootView;
            this.user_item_img = (ImageView) rootView.findViewById(R.id.user_item_img);
            this.user_item_name = (TextView) rootView.findViewById(R.id.user_item_name);
        }

    }
}
